<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<script type="text/javascript">
			function km(){
				   var num1=prompt("请输入考试科目数量","");
				var n1=parseInt(num1);
				var count=0;
				for (i=0;i<n1;i++) {
					var num2=prompt("请输入+"+i+"+考试科目成绩","");
					var n2=parseInt(num2);   
					if(n2<0){
						alert("成绩不能为负数");
					}
					else{
					count = count+n2;
					}
				}
				alert(count);
			}
		</script>
	</head>
	<body>
		<input name="q" type="button"  value="统计考试科目成绩" onclick="km()" >
	</body>
</html>
